var execute = function(script, input, callback) {

    var options = {
        host: '10.10.10.1',
        path: '/?script='+require('querystring').escape(script),
        port: 8888,
    };

    var request = require('http').request(options, function(result) {
        result.setEncoding('utf8');

        var jsondata = '';

        result.on('data', function(chunk) {
            jsondata += chunk;
        });

        result.on('end', function() {            
            var resultset = JSON.parse(jsondata);
            var jabaResult = require('./jabaResult');
            
            callback(new jabaResult.JabaResult(resultset));
        });
    });

    request.on('error', function(e) {
        console.log('  >> node.request: problem with request: ' + e.message);
        console.log('  >> node.request: url: ' + options.host + ":" + options.port + options.path);
        console.log('  >>');
        console.log('  >> node.request: Script:');
        console.log('  >> node.request: ' + script);
    });

    request.setTimeout(2500, function() {
        request.abort();
    })

    request.end();
};

exports.execute = execute;